/*
*
* 半透明面
* r: 半边长
*
 */
function TransparentFace_bufferInit(gl, r=1) {

    //创建位置
    const positions = [
        -r, r, r,
        -r, r, -r,
        -r, -r, -r,
        -r, -r, r,
    ];

    const positionBuf = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, positionBuf);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);

    //创建法矢
    const normals = [
        -1, 0, 0,
        -1, 0, 0,
        -1, 0, 0,
        -1, 0, 0,
    ];

    const verticeNormalBuf = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, verticeNormalBuf);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normals), gl.STATIC_DRAW);

    //创建颜色
    const color = [0.6, 0.8, 0.1, 0.5];

    var faceColors = [];

    for (var i = 0; i < 4; i++) {
        faceColors = faceColors.concat(color);
    }

    const colorBuf = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, colorBuf);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(faceColors), gl.STATIC_DRAW);

    const surfaces = [
        0, 1, 2,    0, 2, 3,
    ];

    const surfaceBuf = gl.createBuffer();
    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, surfaceBuf);
    gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(surfaces), gl.STATIC_DRAW);

    return {
        position: positionBuf,
        color: colorBuf,
        surface: surfaceBuf,
        normal: verticeNormalBuf,
        drawmode: gl.TRIANGLES,
        drawcount: 6,
        transparent: true,
    };
}